|
|
|
|
|
|
|
Because the property pAccountNumber is publicly available, the value of the private module-level variable mvarpAccountNumber is also publicly available, even though the variable mvarpAccountNumber itself is not. This public availability of an attribute is an example of encapsulation. |
|
|
|
|
|
|
|
|
Are forms in Visual Basic really classes? Technically speaking, they are. They have methods and properties like other classes. For many programmers, they have also become convenient modules for housing vast amounts of complex business processing logic, algorithmic engines, and the heart of the application architecture in general. In the Visual Basic community, this is the norm rather than the exception. |
|
|
|
|
|
|
|
|
Programmers who have used forms as all-purposes classes should keep in mind that Microsoft did not add classes to Visual Basic out of the blue. There's actually a nice paradigm shift in the industry away from simply sticking tons of code into forms and global code modules to thinking through, and documenting, how to partition the complexities of software specifications into simpler, nicely encapsulated classes that are responsible for carrying out a particular application behavior. These classes maintain information about their own state as each public and private method is invoked. |
|
|
|
|
|
|
|
|
Yes, Microsoft's Visual Basic team made forms appear in order to exhibit characteristics of classes. In fact, you can add methods and properties to forms just as you would with classes. However, because this feature is available does not mean that programmers should pack a bunch of methods and variables into it. Each individual programmer might know which application behavior the form carries out, but there's a good chance that no one else on the team does. Forms are only responsible for gathering information from human actors (users) and, as the result of a series of internal processes, displaying expected information to those same actors. Classes acting together as subsystems carry out the core behavior of the application. |
|
|
|
|
|
|
|
|
New Term: A group of classes that collaborate within a subsystem to carry out a broader application behavior is known as a package. |
|
|
|
|
|
|
|
|
Forms delegate non-form-like functionality to classes, more specifically, the public methods of classes. Private class methods are used by the class as ancillary methods to carry out the publicly available method's interface. The simplest way to see how forms delegate behavior to classes is through the following code snippet, entered in the General Declarations section of a code module: |
|
|
|
|
|
|
|
|
Global clsMyClass As CMyClass 'Declared, but now memory allocation with
'New |
|
|
|
|
|